import os

os.environ['PYTHONPATH'] = os.environ['PYTHONPATH'] + ":/home/liushuai/caffe/python"
print(os.environ['PYTHONPATH'])
import caffe


def inference(path, prototxt, caffemodel, image):
    MODEL_FILE = '/home/liushuai/caffe/models/test_googlenet/test_googlenet_iter_120000.caffemodel'

    PRETRAINED = path + '/' + caffemodel

    IMAGE_FILE = os.path.join('/tmp/flower_photos/export/train/daisy', '99306615_739eb94b9e_m.jpg')

    input_image = caffe.io.load_image(IMAGE_FILE, color=False)

    net = caffe.Classifier(MODEL_FILE, PRETRAINED)

    prediction = net.predict([input_image], oversample=False)

    caffe.set_mode_cpu()

    print(prediction[0])

    print('predicted class:', prediction[0].argmax())
if __name__ == "__main__":
    model_path = '/home/liushuai/caffe/models/test_googlenet'
    MODEL_FILE = '/home/liushuai/caffe/models/test_googlenet/test_googlenet_iter_120000.caffemodel'
    inference()